package com.softeware.control;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

//@WebServlet(name = "servletTest", value = "/ServletTest")
@WebServlet("/ServletTest")
public class ServletTest extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置响应的MIME类型，必须设置，否则输出中文乱码
        response.setContentType("text/html;charset=utf-8");
        //获得一个向客户发送数据的输出流
        int num = Integer.parseInt(request.getParameter("num"));
        PrintWriter out=response.getWriter();
        out.println("<HTML> <BODY>");
        out.println("Hello！Hello！");
        out.println(num+"分!");
        out.println("很好,很聪明!");
        out.println("</body> </html>");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}